package cola.rh.System.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @Name: Knife4jConfig
 * @Author: Cola
 * @Time: 2023/3/7 16:24
 * @Description:  Knife4jConfig
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    /**
     * AdminApi 配置
     *
     * @return Docket
     */
    @Bean
    public Docket adminApiConfig() {

        /*
        配置分组信息
        */
        Docket adminApi = new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select()
                /*
                 * 只显示admin路径下的页面
                 * */
                .apis(RequestHandlerSelectors.basePackage("cola.rh"))
                .paths(PathSelectors.regex("/v1/api/.*"))
                .build();
        return adminApi;
    }

    /**
     * AdminApi 信息
     *
     * @return ApiInfo
     */
    private ApiInfo adminApiInfo() {

        return new ApiInfoBuilder()
                .title("HelloSpringBoot-API文档")
                .description("本文档描述了HelloSpringBoot系统微服务接口定义")
                .version("1.0")
                .contact(new Contact("Cola", "https://gitee.com/cola0223", "1203952894@qq.com"))
                .build();
    }
}
